
namespace DL.UIBinding
{
    public static class UIBindingExt
    {
        public static T GetOrAddItem<T>(this Collection<T> coll,int index) where T : Context,new()
        {
            var item = coll.GetItem(index);
            if (item == null)
            {
                item = new T();
                coll.Add(item);
            }

            return item;
        }

        public static void RemoveOutItem<T>(this Collection<T> coll, int index) where T : Context
        {
            var count = coll.Count;
            for (int i = count; i > index; i--)
            {
                coll.Remove(i - 1);
            }
        }

    }
}